//
//  IndexMainViewController.m
//  BJYShoppingMall
//
//  Created by Coder on 15/9/23.
//  Copyright © 2015年 BJY12. All rights reserved.
//

#import "IndexMainViewController.h"
#import "UIBarButtonItem+CommomBarButtonItem.h"
#import "BeseHttpClient.h"
#import "ParseJson.h"
#import "NJKWebViewProgressView.h"
#import "NJKWebViewProgress.h"
#import "MBProgressHUD.h"
#import "AppDelegate.h"

@interface IndexMainViewController ()
{
    BeseHttpClient * request;
    ParseJson      * parseJson;
    NJKWebViewProgressView *_progressView;
    NJKWebViewProgress *_progressProxy;
    MBProgressHUD *HUD;

}


@end

@implementation IndexMainViewController
#pragma mark -  视图生命周期

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //初始化浏览器
    [baseWebView.scrollView setContentInset:UIEdgeInsetsMake(44,0,0,0)];
    self.tabBarController.tabBar.hidden = YES;
    
    //开启统计
//    [MobClick beginLogPageView:Tag_Index];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        //屏幕像四周延伸方式
        self.edgesForExtendedLayout = UIRectEdgeAll;
        //自动调整滚动视图
        self.automaticallyAdjustsScrollViewInsets=NO;
    }
    
    [baseWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.zlc99.com/"]]];
    
    [self setNaviBar];
    
    if (!parseJson) {
        parseJson = [[ParseJson alloc]init];
    }
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self initTitle];
    //显示tabbar
    self.tabBarController.tabBar.hidden=YES;
    
    //结束统计
//    [MobClick endLogPageView:Tag_Index];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    //视图消失让tabbar加个动画，避免太过生硬
    /*
     CATransition *tran=[CATransition animation];
     [tran setDuration:1];
     [tran setType:@"rippleEffect"];//cube
     [self.tabBarController.view.layer addAnimation:tran forKey:nil];
     */
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)setNaviBar{
    
    self.navigationItem.leftBarButtonItems  = NULL;
    self.navigationItem.rightBarButtonItem  = NULL;
//    [self initTitle];
    
}


-(void)webViewDidFinishLoad:(UIWebView *)webViewTarget
{
    [super webViewDidFinishLoad:webViewTarget];
    
    [self initTitle];

}
#pragma mark - 设置标题文字
-(void)initTitle
{
    NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],UITextAttributeTextColor,[UIFont boldSystemFontOfSize:22],UITextAttributeFont, nil];
    [self.navigationController.navigationBar setTitleTextAttributes:attributes];
    self.navigationItem.title =@"众乐城";
    
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem createLeftImgBBTframe:CGRectMake(0, 0, 40, self.navigationController.navigationBar.bounds.size.height) imgName:@"index_saomiao" isShowArrow:YES isShowTitle:NO target:self action:@selector(leftbtnAction:)];
//    
//    self.navigationItem.rightBarButtonItem = [UIBarButtonItem createRightImgBBTframe:CGRectMake(0, 0, 80, self.navigationController.navigationBar.bounds.size.height) imgName:@"index_fangdajing" isShowArrow:YES isShowTitle:NO target:self action:@selector(rightbtnAction:)];
    
    self.navigationItem.leftBarButtonItems  = NULL;
    self.navigationItem.rightBarButtonItem  = NULL;
}





/*
 *  打开本地照片，选择图片识别
 */
- (void)openLocalPhoto
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
    picker.delegate = self;
    
    
    picker.allowsEditing = YES;
    
    
    [self presentViewController:picker animated:YES completion:nil];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.

 }
*/

@end
